package com.xxx.converter;

import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

/**
 * @author WXH
 * @version 1.0
 * @program:yebback
 * @date 2022/3/10 20:01
 * @description: 日期转换
 */
@Component
public class DateConverter implements Converter<String,LocalDate> {

    /**
     * 将前端传过来的日期信息进行转换
     * @param source
     * @return
     */
    @Override
    public LocalDate convert(String source) {
        try {
            return LocalDate.parse(source,DateTimeFormatter.ofPattern("yyyy-MM-dd"));
        } catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
}
